﻿<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="MetroContractSample.FileOpenPickerPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MetroContractSample"
    xmlns:common="using:MetroContractSample.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:ExtensionType="FileOpenPicker">

    <UserControl.Resources>
        <CollectionViewSource x:Name="filesViewSource" Source="{Binding Files}"/>
    </UserControl.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the command area
        * Row 1 contains the rest of the page layout
    -->
    <Grid x:Name="layoutRoot" Background="{StaticResource ApplicationPageBackgroundBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="80"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Command area -->
        <Grid x:Name="commandGrid" Margin="120,20,120,30">
            <Button
                AutomationProperties.AutomationId="GoUpButton"
                AutomationProperties.Name="Go Up"
                Content="Go up"
                Click="GoUpButton_Click"
                IsEnabled="{Binding CanGoUp}"
                Margin="-3,-3,37,0"
                Style="{StaticResource TextButtonStyle}"/>
        </Grid>

        <!-- Horizontal scrolling grid of files fills the remainder -->
        <ScrollViewer
            AutomationProperties.AutomationId="FileGridScrollViewer"
            Grid.Row="1"
            Margin="0,-4,0,0"
            Style="{StaticResource HorizontalScrollViewerStyle}">

            <GridView
                x:Name="fileGridView"
                AutomationProperties.AutomationId="FileGridView"
                AutomationProperties.Name="Files"
                ItemsSource="{Binding Source={StaticResource filesViewSource}}"
                ItemTemplate="{StaticResource StandardFileWithTooltip190x130ItemTemplate}"
                SelectionMode="Multiple"
                SelectionChanged="FileGridView_SelectionChanged"
                Margin="116,0,116,46"/>
        </ScrollViewer>

        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup>
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="fileGridView" Storyboard.TargetProperty="Margin">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="96,0,86,56"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="commandGrid" Storyboard.TargetProperty="Margin">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="100,20,90,30"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</common:LayoutAwarePage>
